Skip to content

Point Zen's policy at the directory the package uses - #12148

Open
JoshJAL wants to merge 7 commits into
omacom:quattrofrom
JoshJAL:fix-zen-policy-path
Open

JoshJAL wants to merge 7 commits into
omacom:quattrofrom
JoshJAL:fix-zen-policy-path

Conversation

@JoshJAL

@JoshJAL JoshJAL commented Sep 16, 2026 •

Copy link
Copy Markdown

omarchy install browser zen writes Zen's Firefox policy to /opt/zen-browser/distribution, but zen-browser-bin installs to /opt/zen-browser-**bin**.

Nothing fails. install -d happily creates the missing directory, so the policy lands somewhere no package owns and Zen never reads, and the installer reports success. The result is that every preference Omarchy sets for Firefox-based browsers is silently dropped for Zen:

apz.overscroll.enabled
media.ffmpeg.vaapi.enabled                  <- hardware video decode
media.hardware-video-decoding.force-enabled
widget.disable-swipe-tracker
widget.wayland.fractional-scale.enabled     <- Wayland fractional scaling

and an orphan /opt/zen-browser/ is left behind on every machine that ran the installer.

BROWSER_POLICY_FIREFOX_DIRS carried the same path, so the migration that hardens those directories (migrations/1787515927.sh) has been guarding the wrong directory too.

Observed on a machine where Zen was installed through omarchy install browser zen:

$ pacman -Ql zen-browser-bin | grep -c '^zen-browser-bin /opt/zen-browser/'
0
$ find /opt/zen-browser
/opt/zen-browser
/opt/zen-browser/distribution
/opt/zen-browser/distribution/policies.json   <- omarchy's, read by nothing

$ cat /opt/zen-browser-bin/distribution/policies.json   <- what Zen actually reads
{ "policies": { "DisableAppUpdate": true, "DefaultSerialGuardSetting": 3 } }

Firefox is unaffected: its path is correct.

Why the second commit

Once the path is right, install -T lands on a file zen-browser-bin ships, and Omarchy's policy would replace the vendor's — dropping DisableAppUpdate and letting a browser pacman manages start updating itself behind the package manager, on a file pacman owns.

browser_policy_setup_firefox_distribution already accepts the policies file as its second argument, so Zen gets its own: the same preferences Firefox receives plus the two keys the package sets. Firefox keeps using the stock file — its package ships distribution.ini but no policies.json, so there is nothing there to preserve.

I tried merging with jq first and backed it out. [[ -f $target ]] is true for a symlink to a regular file, so merging read through a planted link and folded its contents into machine policy — browser-policy-dir-test.sh and default-apps-test.sh both caught it. Passing a separate file avoids that surface entirely, and leaves Firefox's install path byte-identical.

If you would rather not carry a second policies file, the first commit stands alone and fixes the path; Zen then loses DisableAppUpdate until the package reinstalls it.

Testing

./test/all, with the four assertions that pinned the old path updated. Six suites fail on my machine both with and without this branch (config, locate, omarchy-kernel-migration, runtime-smoke, snapper, unowned-system-paths) and look environment-dependent; everything touching browsers, policies and defaults passes.

Not included: a migration to remove the orphan /opt/zen-browser/ from machines that already ran the old installer. Happy to add one if you want it.

Fixes #7411

omarchy-install-browser wrote Zen's Firefox policy to
/opt/zen-browser/distribution, but zen-browser-bin installs to
/opt/zen-browser-bin. Nothing failed: install -d created the missing
directory, so the policy landed in a path no package owns and Zen never
reads, and the install reported success.

The effect is that every preference Omarchy sets for Firefox-based
browsers was silently dropped for Zen -- VA-API and hardware video
decoding, Wayland fractional scaling, overscroll and the swipe tracker --
while leaving an orphan /opt/zen-browser behind on every machine that ran
the installer.

BROWSER_POLICY_FIREFOX_DIRS carried the same path, so the migration that
hardens those directories was guarding the wrong one too.
zen-browser-bin ships distribution/policies.json carrying DisableAppUpdate
and DefaultSerialGuardSetting. Now that the path is right, install -T
lands on that file, so Omarchy's policy would replace the vendor's and let
a browser pacman manages start updating itself behind the package manager.

browser_policy_setup_firefox_distribution already takes the policies file
as its second argument, so give Zen its own: the same preferences Firefox
gets, plus the two keys the package sets. Nothing else changes, and
Firefox keeps using the stock file -- its package ships distribution.ini
but no policies.json, so there is nothing there to preserve.

@Jamesking56 Jamesking56 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realised you don't have a migration script to fix users who currently have Zen enabled.

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for the careful write-up. The path fix works, and I've marked this verified at f3ab9c9. It isn't ready: the maintainer has a decision to make first, set out below.

What I checked, on a worker built from the Omarchy ISO with zen-browser-bin 1.22.3b:

  • On quattro, omarchy install browser zen writes to an orphan /opt/zen-browser/distribution/policies.json, and Zen's about:policies lists only the package's DisableAppUpdate and DefaultSerialGuardSetting.
  • On this branch, /opt/zen-browser-bin/distribution/policies.json holds both package policies plus Omarchy's five preferences, and about:policies lists all three policies as active.
  • The tests: default-apps-test.sh and browser-policy-dir-test.sh pass on this head and when it is merged into current quattro. With the installer and the helper put back to quattro's versions, each of those files fails one assertion. The full suite on the merged tree fails the same tests that quattro fails on the same worker, and nothing else.

This fixes #7411, so I've added it to the description. It competes with #7444, which fixes the same bug by merging Omarchy's preferences into the package's file with jq. Codex Medium compared the two separately and preferred this one, as I did. This one uses the existing hardened helper, never reads a file that could have been planted, and is much smaller. The jq merge in #7444 is shallow, so it would replace any Preferences the package ships, and it would install an empty file as-is.

What is still open:

  • The preferences don't survive a Zen upgrade. zen-browser-bin declares no backup files, so pacman puts back its own policies.json on every update. Reinstalling the same package on the worker left only the package's two policies. This is the open question on zen: write preferences to the path Zen reads and merge with package policies #7444 too. One option is a pacman hook that re-applies the file after each upgrade. The other is /etc/zen/policies/policies.json, which pacman leaves alone and which replaces the distribution file rather than merging with it. Either way Omarchy would ship its own copy of DisableAppUpdate, which is what this PR's zen-policies.json already does. That decision is the maintainer's, and it is what this waits on.
  • Existing Zen installs get nothing from this change, which @Jamesking56 raised. migrations/1787515927.sh now covers the right directory but only hardens it. It keeps the package's file and doesn't add Omarchy's preferences. How a migration should repair existing installs depends on where the file ends up, so it belongs with the decision above.
  • One edge case in that migration. If Zen's policies.json is missing or untrusted (not root-owned, or group- or world-writable), the repair branch at migrations/1787515927.sh:28 installs the generic Firefox policies.json there, dropping DisableAppUpdate. Before this change the migration never touched Zen's real directory. It only fires on a tampered directory, and the fix depends on the same decision, so I've left it for that.
  • Not from this PR: Zen rejects apz.overscroll.enabled ("Preference not allowed for stability reasons"), which comes from the shared default/firefox/policies.json on quattro. The other four preferences apply.

The second opinion was Codex Medium. It found the migration edge case, which I checked against the source. On the rest it agreed with me, but it had read my results first, so its agreement isn't independent. Nothing was pushed to your branch.

@jandrusk

Copy link
Copy Markdown

Verified path fix looks right (/opt/zen-browser-bin/distribution + dedicated zen-policies.json). Competes with #7444 (jq-merge into package policies); this one reuses the hardened helper and avoids reading a plantable file.

Maintainer call between this and #7444 — I'm fine with either once one lands and the other closes.

omarchybot and others added 2 commits November 1, 2026 11:26
quattro dropped the migration assertions from browser-policy-dir-test.sh (omacom#16302) and renamed the Zen path check's pass line; keep quattro's version with this branch's /opt/zen-browser-bin path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quattro added DontCheckDefaultBrowser to default/firefox/policies.json so Firefox-based browsers stop asking to be the default behind Omarchy's link routing (omacom#14441). zen-policies.json was copied from the stock file before that, so Zen would still ask. Add the key, and test that Zen's file carries every policy the stock one does so the two cannot drift again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no outstanding findings.

Summary

Points Zen’s policy setup at /opt/zen-browser-bin/distribution.

  • Zen now reads Omarchy's browser policies from its package folder.

No new actionable issues found in the changes since the previous review.

Reviews (4) · Last reviewed commit: "Drop the tests that restate the implemen..." · Reviewed by Greptile

Comment thread install/helpers/browser-policy.sh Resolved
The drift test deleted Zen's two package keys before comparing, so it passed with them missing, and compared jq output in file order, so reordering keys failed it. Assert the two keys explicitly and sort keys on both sides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This had stopped merging cleanly into quattro, so I brought it up to date and pushed three commits to your branch. It is verified again at f0903be. It is still waiting on the same maintainer decision as before.

What I pushed:

  • A merge of quattro (1471325). The only conflict was in test/shell.d/browser-policy-dir-test.sh, where quattro had removed the migration assertions in Remove migration tests #16302. I kept quattro's version, with your /opt/zen-browser-bin path. Everything else merged cleanly.
  • DontCheckDefaultBrowser in zen-policies.json (ecc90cb). Since you opened this, Route links from every app through the running default browser #14441 added that policy to default/firefox/policies.json so that Firefox-based browsers stop asking to become the default. Your Zen copy was made before Route links from every app through the running default browser #14441, so Zen would have kept asking. I added the key, plus a test that zen-policies.json matches the stock file apart from the package's two keys, so the two files can't drift apart unnoticed.
  • A stronger version of that test (f0903be). It now also checks that DisableAppUpdate and DefaultSerialGuardSetting are present, and it compares the two files with keys sorted.

What I checked, on a worker built from the Omarchy ISO with zen-browser-bin 1.24b:

  • On quattro, omarchy install browser zen still writes to an orphan /opt/zen-browser/distribution/policies.json, and Zen's real file keeps only the package's two policies.
  • On this branch, /opt/zen-browser-bin/distribution/policies.json holds the package's two policies, DontCheckDefaultBrowser and Omarchy's five preferences, and no /opt/zen-browser is created. I checked the file itself. Unlike last time, I did not open about:policies.
  • The tests: default-apps-test.sh and browser-policy-dir-test.sh pass on this head. Each one fails a Zen path assertion when the installer and helper are put back to quattro's versions. The full shell suite at ecc90cb fails the same four tests that quattro fails on the same worker, and nothing else. The two browser tests also passed at f0903be, which changes only the test.

Still open, unchanged from my last comment:

  • Reinstalling the package wipes Omarchy's file. Reinstalling zen-browser-bin put back the package's own two-key policies.json. Choosing between a pacman hook and /etc/zen/policies/policies.json is the maintainer's call.
  • Existing Zen installs are not repaired. The repair branch at migrations/1787515927.sh:28 would install Firefox's generic file into Zen's directory, dropping DisableAppUpdate, but only when that directory has been tampered with. One new interaction: migrations/1791935188.sh now reaches Zen's real directory. On a hardened directory it only adds DontCheckDefaultBrowser and keeps the package's keys, which is fine.
  • This still competes with zen: write preferences to the path Zen reads and merge with package policies #7444, which is open and unchanged.

The second opinion was Codex Medium and muse-wonder via pi at high thinking. Both found the merge resolution correct. Both raised the migration repair edge case above again. Both pointed out that my first drift test passed even with the package's keys missing and broke if keys were reordered, which f0903be fixes. They were reviewing my commits, so their agreement on the rest isn't independent.

The browser-policy hardening migration repairs every directory in BROWSER_POLICY_FIREFOX_DIRS by calling browser_policy_install_firefox_policies with no file, which installed Firefox's stock policies. Now that the list names Zen's real directory, a repair there would drop the package's DisableAppUpdate and DefaultSerialGuardSetting. The helper now picks the file by directory, so the shipped migration, the installer and any later caller get zen-policies.json for Zen without naming it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: muse-wonder High <noreply@meta.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

I pushed one more commit to your branch (f31077e). It fixes the case Greptile raised as P1 above, which my last comment listed as still open. The PR is verified again at f31077e and still waits on the maintainer.

What was wrong. migrations/1787515927.sh repairs every directory in BROWSER_POLICY_FIREFOX_DIRS. When a directory is not hardened and its policies.json is missing or unsafe, it calls browser_policy_install_firefox_policies "$dir" without naming a file, and that installed Firefox's stock policies. Now that the list names Zen's real directory, that repair would drop the package's DisableAppUpdate and DefaultSerialGuardSetting.

The fix. browser_policy_firefox_default_policies in install/helpers/browser-policy.sh picks the file by directory: zen-policies.json for /opt/zen-browser-bin/distribution and the stock file for everything else. browser_policy_install_firefox_policies and browser_policy_setup_firefox_distribution default to it. The migration has already shipped, so it stays as it is. It gets the right file through the helper it already sources. The installer no longer has to name zen-policies.json itself. One test in browser-policy-dir-test.sh checks the mapping for both directories.

What I checked, on a worker built from the Omarchy ISO with zen-browser-bin 1.24b. I removed Zen's policies.json, set its directory to 775 and ran the migration:

  • From f0903be, Zen's file came back without DisableAppUpdate and DefaultSerialGuardSetting.
  • From f31077e, both keys were kept, along with DontCheckDefaultBrowser and Omarchy's five preferences.
  • With the fix reverted, both keys were dropped again.

browser-policy-dir-test.sh, default-apps-test.sh, platform-app-hooks-test.sh and ./test/cli pass at this head. I did not rerun the full shell suite this time. It last ran at ecc90cb.

Second opinion. Codex at medium effort and muse-wonder at high effort reviewed the commit and the whole diff. Neither found a functional problem. Both checked every caller and confirmed that Firefox and any caller passing an explicit file behave as before. Both pointed out an unquoted string literal, and I fixed it before pushing. They reviewed my own change, so their agreement is not independent.

Still open, for the maintainer:

  • Reinstalling or upgrading zen-browser-bin puts back the package's two-key policies.json, which drops Omarchy's preferences. Whether to handle that with a pacman hook or /etc/zen/policies/policies.json is the maintainer's call.
  • Nothing removes the orphan /opt/zen-browser/ left on machines that ran the old installer.
  • This still competes with zen: write preferences to the path Zen reads and merge with package policies #7444, which is open and unchanged.

Comment thread test/shell.d/browser-policy-dir-test.sh Resolved
One grepped the helper for Zen's path and one re-read zen-policies.json for the two package keys it was written with; AGENTS.md rules out both. The mapping test and default-apps-test.sh's installer assertions still check where Zen's policies go, and the parity check still catches the two policy files drifting apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: muse-wonder High <noreply@meta.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

I pushed one commit to your branch (05b50ab). It takes Greptile's P2 above: test/shell.d/browser-policy-dir-test.sh no longer greps install/helpers/browser-policy.sh for Zen's path. The base branch's AGENTS.md rules out tests that restate the implementation, and that grep would have passed even with the path wrong in BROWSER_POLICY_FIREFOX_DIRS, because the selector names the same string. The same commit drops a check I added earlier, which re-read zen-policies.json for the two package keys it was written with. The test of browser_policy_firefox_default_policies and the installer assertions in default-apps-test.sh still cover where Zen's policies go. The parity check still catches zen-policies.json falling behind policies.json. Nothing outside the test file changed.

What I checked, on a worker built from the Omarchy ISO with zen-browser-bin 1.24.2b. I ran the real omarchy-install-browser zen from three trees:

  • On current quattro (3b36b9e), Zen's policies.json kept only the package's two keys, and the installer wrote an orphan /opt/zen-browser/distribution.
  • At this head, Zen's file gained DontCheckDefaultBrowser and Preferences and kept DisableAppUpdate and DefaultSerialGuardSetting. No orphan was written.
  • With the change to the installer and helper reverted, the result matched quattro again.

browser-policy-dir-test.sh, default-apps-test.sh, platform-app-hooks-test.sh and ./test/cli pass. The full shell suite has 6 failing files: agent-account-exec, ascii, background-intro-lifecycle, branding-about-animation, first-run and runtime-smoke. All 6 also fail on this branch's merge base, 5df8f9e, and none of them touches browser policy.

Second opinion. Codex at medium effort and muse-wonder at high effort reviewed the whole diff against current quattro, including both migrations that walk BROWSER_POLICY_FIREFOX_DIRS. Neither found a functional defect. Both agreed the grep should go. Both flagged the package-key check, which is why it is gone too. A second round on the final commit found nothing. They reviewed my own change, so their agreement is not independent.

The PR is verified at 05b50ab. It still waits on the maintainer for what my last comment listed: a zen-browser-bin upgrade or reinstall restores the package's two-key policies.json, nothing removes the orphan /opt/zen-browser/ on machines that ran the old installer, and #7444 still competes with this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zen installer writes policies to unused /opt/zen-browser path

4 participants